<?php //Seyret Component v.0.3//
/**
* @package Seyret
* @version 0.3
* @copyright Copyright (C) 2008 Mustafa DINDAR. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Seyret Video Component is a free software.
* See seyrettos.html for license notices and details.
*/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

$document = & JFactory::getDocument();


$jslink=JURI :: root()."components/com_seyret/includes/js/swfobject.js";
$document->addScript($jslink);


$jslink=JURI :: root()."components/com_seyret/includes/js/seyreteditvideo.js";
$document->addScript($jslink);


$user =& JFactory::getUser();
$userid=$user->id;
$husertype=bin2hex($user->usertype);

$lang =& JFactory::getLanguage();
$language=$lang->_lang;		
		
$videodata=$this->videodata;

echo $this->toolbar;
echo $this->modtoolbar;

$session =& JFactory::getSession();
$seyretmessagetype=$session->get('seyret.messagetype');
$seyretmessage=$this->seyretmessage($seyretmessagetype);
$session->clear('seyret.messagetype');

$registry=$this->registry;



$uploadmaxsize = ini_get("upload_max_filesize") * 1024* 1024;

$prandom=rand(9000,100000);
		
?>







 <script type="text/javascript">



 
jQuery(document).ready(function(){

	jQuery.seyrettools.createmultibox("flash", "datepicker1", null , null , null ,  "inputfield=publishstart&amp;dateformat=d-m-y&amp;div=publishstart&amp;key=<?php echo $this->reglocal->seyretswfprokey; ?>");	
	jQuery.seyrettools.createmultibox("flash", "datepicker2", null , null , null ,  "inputfield=publishend&amp;dateformat=d-m-y&amp;div=publishend&amp;key=<?php echo $this->reglocal->seyretswfprokey; ?>");
	jQuery.seyrettools.createmultibox("flash", "datepicker3", null , null , null ,  "inputfield=addeddate&amp;dateformat=d-m-y&amp;div=addeddate&amp;key=<?php echo $this->reglocal->seyretswfprokey; ?>");
	
	jQuery.seyrettools.createmultibox("flash", "uploadvideo", null , null , null , "lng=<?php echo $language;?>&amp;sidt=<?php echo $this->sidt;?>&amp;task=uploadvideo&amp;uptype=video&amp;siteurl=<?php echo JURI :: root(); ?>&amp;uid=<?php echo $userid;?>&amp;maxfilesize=<?php echo $uploadmaxsize;?>&amp;utype=<?php echo $husertype;?>&amp;key=<?php echo  $this->reglocal->seyretswfprokey;?>&amp;skin=<?php echo JURI::root()."components/com_seyret/includes/tools/swf/defaultuploaderskin.swf"; ?>");


	jQuery("#videoinputformadmintoggler").click(function () {
      jQuery("#videoinputformadmin").slideToggle("slow");
    });

});


function completeadplugin(advalue) {
	document.getElementById('defaultcontentad').value = advalue;
	eval('cpeditorbox.close()');
}

function getadpluginvalues() {
	var value = $('defaultcontentad').get('value');


	sendToActionScript("adpluginswfobject", value);
}


function updatedatefield(field, date, div){

	document.getElementById(field).value = date;

}


function getvideoxmlcomplete(err, msg, vtt, vds, vth, vst, vsc, vtags, vdurat, vlink) {

	if ( err == "1" ) {
		jQuery('#videoservervideolinkresult').html(msg).addClass('videoservererror').removeClass('videoserverok');
	} else {
		jQuery('#videoservervideolinkresult').html(msg).addClass('videoserverok').removeClass('videoservererror');
	}
		
	jQuery('#videotitle').attr('value', vtt);
	jQuery('#videodescription').attr('value', vds);
	jQuery('#videothumbnail').attr('value', vth);
	jQuery('#videoservertype').attr('value', vst);
	jQuery('#videoservercode').attr('value', vsc);
	jQuery('#videotags').attr('value', vtags);
	jQuery('#duration').attr('value', vdurat);
	jQuery('#videourl').attr('value', vlink);
	if (vth!="")  {
		jQuery('#pvideothumbnailimg').html('');
		jQuery(document.createElement("img")).attr("src",vth).appendTo('#pvideothumbnailimg').attr('id', 'vthumbnail').attr('name', 'vthumbnail').addClass('videothumbnailimg');
		
		jQuery('#pvideothumbnailimg').addClass('pvideothumbnailimg');
		
	}
}

function validate_form(thisform)
{
	with (thisform)
	{
		 
		if (jQuery('#videotitle').attr('value')=="") {
			jQuery('#videotitle').removeClass('seyretinputbox').addClass('redseyretinputbox');
			var returnvalue="false";
		} else {
			jQuery('#videotitle').removeClass('redseyretinputbox').addClass('seyretinputbox');
		}
		
		if (jQuery("#parentcat").attr('value')=="") {
			jQuery("#parentcat").removeClass('seyretinputbox').addClass('redseyretinputbox');
			var returnvalue="false";
		} else {
			jQuery("#parentcat").removeClass('redseyretinputbox').addClass('seyretinputbox');
		}
		
	
		if (jQuery("#videoservertype").attr('value')=="") {
			jQuery("#videoservertype").removeClass('seyretinputbox').addClass('redseyretinputbox');
			var returnvalue="false";
		} else {
			jQuery("#videoservertype").removeClass('redseyretinputbox').addClass('seyretinputbox');
		}	
	
		if (jQuery("#videoservercode").attr('value')=="") {
			jQuery("#videoservercode").removeClass('seyretinputbox').addClass('redseyretinputbox');
			var returnvalue="false";
		} else {
			jQuery("#videoservercode").removeClass('redseyretinputbox').addClass('seyretinputbox');
		}	

		
		
		if (jQuery("#published").length > 0 ){

			if (jQuery("#published").attr('value')=="") {
				jQuery("#published").removeClass('seyretinputbox').addClass('redseyretinputbox');
				var returnvalue="false";
			} else {
				jQuery("#published").removeClass('redseyretinputbox').addClass('seyretinputbox');
			}
		}

		
		
		if (jQuery("#featured").length > 0) {
			if (jQuery("#featured").attr('value')=="") {
				jQuery("#featured").removeClass('seyretinputbox').addClass('redseyretinputbox');
				var returnvalue="false";
			} else {
				jQuery("#featured").removeClass('redseyretinputbox').addClass('seyretinputbox');
			}
		}

		if (jQuery("#downloadable").length > 0) {
			if (jQuery("#downloadable").attr('value')=="") {
				jQuery("#downloadable").removeClass('seyretinputbox').addClass('redseyretinputbox');
				var returnvalue="false";
			} else {
				jQuery("#downloadable").removeClass('redseyretinputbox').addClass('seyretinputbox');
			} 
		}
		
		
	}
	
	
	if (returnvalue=="false") {
		return false;
	}
}


function openuploadbox() {
	jQuery("#videouploadlink").click();
}






function completeuploadprocess(fileurl, thumburl) {
	
	
	jQuery('#videoservervideolinkresult').html('<?php echo JText::_('Video is uploaded successfully'); ?>').addClass('videoserverok').removeClass('videoservererror');	

	document.getElementById("videoservercode").value = fileurl;
	document.getElementById("videothumbnail").value = thumburl;
	document.getElementById("videoservertype").value = "localfile";

	
	jQuery('#pvideothumbnailimg').empty();
	
	if (thumburl!="")  {

		jQuery('#pvideothumbnailimg').html('<img id ="vthumbnail" name ="vthumbnail" class ="videothumbnailimg" src = "' + thumburl +'"/>');
		jQuery('#pvideothumbnailimg').addClass('pvideothumbnailimg');
		
	}	
	

	jQuery("#cboxClose").click();


}
</script>


<div>

	<div id="editvideoinfo">
			<?php echo JText::_('Add Video Info'); ?>
	</div>

	
	
	

			<div class="uploadvideolink">
			
			
			<a id="videouploadlink" style="display:none;" href="<?php echo JURI::root()."components/com_seyret/includes/tools/swf/flx/videouploader.swf?"; ?><?php echo $prandom; ?>&amp;width=600&amp;height=350" rel="uploadvideo" title="<?php echo JText::_('Upload Video'); ?>"><span ><?php echo JText::_('Upload Video'); ?></span></a>
			
			
			</div>

			
			<!-- upload video image box *************** END ************* -->	
			<div style="clear:both;"></div>
	
	
			<div id="addvideoflash"  style="padding:10px;" >
				<div id="addvideoflashswf"></div>
			</div>
			

			<script type="text/javascript">
				var flashvars = {}
				flashvars.width = "600"
				flashvars.vserver = "<?php echo $registry->getValue( 'permission.administration.canaddexternalvideos'); ?>"
				flashvars.uploadp = "<?php echo $registry->getValue( 'permission.administration.canuploadvideos'); ?>"
				flashvars.fbrws = "0"
				flashvars.height = "70"
				flashvars.pbcolor = "0xFFFFFF"
				flashvars.lng="<?php echo $language;?>"
				flashvars.key = "<?php echo $this->reglocal->seyretswfprokey; ?>"
				var params = {}
				params.wmode = "transparent"
				params.allowfullscreen = "true"
				var attributes = {}
				attributes.name = "VideoPlayback"
				attributes.id = "VideoPlayback"
				
				swfobject.embedSWF("<?php echo JURI::root(); ?>components/com_seyret/includes/tools/swf/flx/AddVideo.swf", "addvideoflashswf", "602", "72", "9.0.0", "<?php echo JURI::root(); ?>components/com_seyret/includes/tools/swf/expressinstall.swf", flashvars, params, attributes); 
			</script>
	
	<div class="prevresultcontainer">
		<div id="videoservervideolinkresult"></div>
		<div id="pvideothumbnailimg"></div>
	</div>

	<div id="seyretmessage" class="<?php echo $seyretmessagetype;?>">
		<?php echo $seyretmessage;?>
	</div>
	
	<div style="clear:both;"></div>

	<div id="analyzedvideodetails">
			
		<form name="videodetailsform" id="videodetailsform" method="post" action="<?php echo JURI::root(); ?>index.php?option=com_seyret&amp;view=editvideo&amp;task=savevideo" onsubmit="return validate_form(this)">		
				
			<div class="videodetailsinputform">
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Video Title');?></div>
				<div class="seyreteditvideoeditforminput"><input type="text" name="videotitle" id="videotitle" class="editvideoinputbox seyretinputbox" value="<?php echo $videodata->videotitle;?>" /></div>
				<div style="clear:both;"></div>
				
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Video Description');?></div>
				<div class="seyreteditvideoeditforminput"><input type="text" name="videodescription" id="videodescription" class="editvideoinputbox seyretinputbox" value="<?php echo $videodata->videodescription;?>" /></div>
				<div style="clear:both;"></div>
				
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Video Tags');?></div>
				<div class="seyreteditvideoeditforminput"><input type="text" name="videotags" id="videotags" class="editvideoinputbox seyretinputbox" value="<?php echo $videodata->videotags;?>" /></div>
				<div style="clear:both;"></div>
				
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Category');?></div>
				<div class="seyreteditvideoeditforminput"><?php echo $this->parentcatselect;?></div>
				<div style="clear:both;"></div>

				<?php 
				//check if secondary categories system is enabled
				if($registry->getValue( 'seyret.front.secondarycategories')=="1") {
				?>
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Secondary Categories');?></div>
				<div class="seyreteditvideoeditforminput"><?php echo $this->parentextracatselect;?></div>	
				<div style="clear:both;"></div>				
				<?php
				}
				
				?>

				<?php 
				//check if secondary categories system is enabled
				if($registry->getValue( 'permission.administration.canselectchannels')=="1") {
				?>
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Video Channel');?></div>
				<div class="seyreteditvideoeditforminput"><?php echo $this->chselectlist;?></div>	
				<div style="clear:both;"></div>				
				<?php
				}
				
				?>
				

				<?php
				if ($this->registry->getValue('permission.administration.canmakefeatured')=="1"){
				?>
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Featured');?></div>
				<div class="seyreteditvideoeditforminput"><?php echo $this->featuredselect;?></div>
				<div style="clear:both;"></div>		



				<?php
				}
							
				?>

				
				<?php
				if ($this->registry->getValue('permission.administration.candisableembed')=="1"){
				?>
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Embedable');?></div>
				<div class="seyreteditvideoeditforminput"><?php echo $this->embedselect;?></div>
				<div style="clear:both;"></div>		



				<?php
				}
							
				?>
				
				
				<?php
				if ($this->registry->getValue('permission.administration.canmakevideodownloadable')=="1"){
				?>				
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Downloadable');?></div>
				<div class="seyreteditvideoeditforminput"><?php echo $this->downloadableselect;?></div>
				<div style="clear:both;"></div>		
				
				<?php
				}
							
				?>				
				

				<?php
				if ($this->registry->getValue('permission.administration.canpublishownvideos')=="1"){
				?>
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Published');?></div>
				<div class="seyreteditvideoeditforminput"><?php echo $this->publishselect;?></div>
				<div style="clear:both;"></div>				
				
				<?php
				}
							
				?>
	
				<?php
				if ($this->registry->getValue('permission.administration.candefinepublishperiod')=="1"){
				?>

				
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Publish Start Date');?></div>
				<div class="seyreteditvideoeditforminput" ><input  style="float:left;"  class="seyretinputbox" id="publishstart" name="publishstart" type="text"  value="<?php echo $videodata->publishstart;?>" /></div>	
				<div style="float:left;"><a href="<?php echo JURI::root()."components/com_seyret/includes/tools/swf/datepicker.swf?width=235&amp;height=300" ?>" rel="datepicker1" class="publishstartol" title="<?php echo JText::_('Publish Start Date');?>"><img src="<?php echo JURI::root()."components/com_seyret/themes/default/images/blank.gif";?>" class="datepickerbutton" alt="" /></a></div>

			

			
				<div style="clear:both;"></div>				

				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Publish End Date');?></div>
				<div class="seyreteditvideoeditforminput" ><input  style="float:left;"  class="seyretinputbox" id="publishend" name="publishend" type="text" value="<?php echo $videodata->publishend;?>" /></div>	
				<div style="float:left;"><a href="<?php echo JURI::root()."components/com_seyret/includes/tools/swf/datepicker.swf?width=235&amp;height=300"; ?>" rel="datepicker2" class="publishendol" title="<?php echo JText::_('Publish End Date');?>"><img src="<?php echo JURI::root()."components/com_seyret/themes/default/images/blank.gif";?>" class="datepickerbutton" alt="" /></a></div>


				<div style="clear:both;"></div>

				<?php
				}
							
				?>
				
		
				<?php
				if ($this->registry->getValue('permission.administration.candefinevideoaccesslevel')=="1"){
				?>
		
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Video Access Permission');?></div>
				<div class="seyreteditvideoeditforminput"><?php echo $this->videoacllist;?></div>
				<div style="clear:both;"></div>				

				<?php
				}
							
				?>

				
				
				<?php
				// this property is disabled temporarily
				
				if ($registry->getValue( 'permission.administration.canaddcontenttovideos') == "disabled temporarily") {
				
				?>
		
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Video Content Overlay');?></div>
				<div class="seyreteditvideoeditforminput">
				<div class="cpeditordiv">
						<a style= "display:block;" id="cpeditor" href="<?php echo JURI::root()."components/com_seyret/includes/tools/swf/cpeditor.swf"; ?>" rel="width:820,height:350" class="cpeditor" title="<?php echo JText::_('Content Editor'); ?>"><span ><?php echo JText::_('Open Editor'); ?></span></a>
						</div>

						
					
						<script type="text/javascript">
								
						
						// var cpeditorbox = {};
						// jQuery(document).ready(function(){
								// cpeditorbox = new multiBox('cpeditor', {
								// descClassName: 'multiBoxDesc', 
								// overlay: new overlay(),
								// iframescrolling: 'no',
								// objectname: 'adpluginswfobject',
								// flashVars:'lng=<?php echo $language;?>&amp;sidt=<?php echo $this->sidt;?>&amp;uptype=video&amp;siteurl=<?php echo JURI :: root(); ?>&amp;uid=<?php echo $userid;?>&amp;key=<?php echo  $this->reglocal->seyretswfprokey;?>&amp;skin=<?php echo JURI::root()."components/com_seyret/includes/tools/swf/defaultcpeditorskin.swf"; ?>'
							// });
						// });

						</script>
						
						<div style="clear:both;"></div>
				</div>		
				
						
						
				<?php
				}
				?>
	
				
			</div>
	
	<?php

	//--------------------------- CAPTCHA -------------------START
	if ($this->registry->getValue('permission.access.addvideocaptcha')=="1"){
	//check registry
	?>
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Security Code');?></div>
				<div class="seyreteditvideoeditforminput"><div style="text-align:center;"><?php echo $this->recaptcha; ?></div></div>
				<div style="clear:both;"></div>


	<?php
	//--------------------------- CAPTCHA -------------------END
	}

	?>
		
		<div class="seyreteditvideoeditformlabel"><?php echo JText::_('After saving this video');?></div>
		
		<div class="seyreteditvideoeditforminput">
		<input type="radio" name="onsubmitreturn" value="addnewvideo"><?php echo JText::_('Add new video');?>
		<input type="radio" name="onsubmitreturn" value="addedvideo" checked><?php echo JText::_('Go to saved video');?>
		</div>




		<div style="clear:both;"></div>
		
		<input type="submit" value="<?php echo JText::_('Save');?>" id="submit" class="seyretbuttonnarrow" />
	
	
			<?php
			if ($this->registry->getValue('permission.administration.canaccssadmnstrtdtlsonaddvideo')=="1"){
			?>
			<div id="videoinputformadmintoggler"><?php echo JText::_('Administrative Details');?></div>
			
			<?php
			}
			
			?>
			<div id="videoinputformadmin" style="display:none;">

			
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Added By');?></div>
				<div class="seyreteditvideoeditforminput"><input type="text" name="addedby" id="addedby" class="seyretinputbox narrowinputbox" value="<?php 
					if ($videodata->addedby=="") $videodata->addedby=$userid;
					echo $videodata->addedby;?>" /></div>
				<div style="clear:both;"></div>	


				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Added Date');?></div>
				<div class="seyreteditvideoeditforminput"><input  style="float:left;" class="seyretinputbox" id="addeddate" name="addeddate" type="text" value="<?php echo $videodata->addeddate;?>" /></div>
					
				<div style="float:left;"><a href="<?php echo JURI::root()."components/com_seyret/includes/tools/swf/datepicker.swf?width=235&amp;height=300"; ?>" rel="datepicker3" class="addeddateol" title="<?php echo JText::_('Added Date');?>"><img src="<?php echo JURI::root()."components/com_seyret/themes/default/images/blank.gif";?>" class="datepickerbutton" alt="" /></a></div>

			

			
				<div style="clear:both;"></div>


				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Video Url');?></div>
				<div class="seyreteditvideoeditforminput"><input type="text" name="videourl" id="videourl" class="editvideoinputbox seyretinputbox" value="<?php echo $videodata->videourl;?>" /></div>
				<div style="clear:both;"></div>				

				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Video Thumbnail');?></div>
				<div class="seyreteditvideoeditforminput"><input type="text" name="videothumbnail" id="videothumbnail" class="editvideoinputbox seyretinputbox" value="<?php echo $videodata->videothumbnail;?>" /></div>
				<div style="clear:both;"></div>
					
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Video Server Type');?></div>
				<div class="seyreteditvideoeditforminput"><input type="text" name="videoservertype" id="videoservertype" class="editvideoinputbox seyretinputbox" value="<?php echo $videodata->videoservertype;?>" /></div>
				<div style="clear:both;"></div>
				
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Video Server Code');?></div>
				<div class="seyreteditvideoeditforminput"><input type="text" name="videoservercode" id="videoservercode" class="editvideoinputbox seyretinputbox" value="<?php echo $videodata->videoservercode;?>" /></div>
				<div style="clear:both;"></div>
				
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Video Duration');?></div>
				<div class="seyreteditvideoeditforminput"><input type="text" name="duration" id="duration" class="editvideoinputbox seyretinputbox" value="<?php echo $videodata->duration;?>" /></div>
				<div style="clear:both;"></div>
				
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Default Content Ad');?></div>
				<div class="seyreteditvideoeditforminput"><input type="text" name="defaultcontentad" id="defaultcontentad" class="editvideoinputbox seyretinputbox" value="<?php echo htmlentities($videodata->defaultcontentad);?>" /></div>
				<div style="clear:both;"></div>
				
				<div class="seyreteditvideoeditformlabel"><?php echo JText::_('Default Content Ad Link');?></div>
				<div class="seyreteditvideoeditforminput"><input type="text" name="defaultcontentadlink" id="defaultcontentadlink" class="editvideoinputbox seyretinputbox" value="<?php echo $videodata->defaultcontentadlink;?>" /></div>
				<div style="clear:both;"></div>

			
			</div>
			
			
			




		 
		 
		<input type="hidden" name="id" value="<?php echo $videodata->id;?>" />

		 </form>

	 </div>
</div> 

